package com.dufang.string01;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;

public class DemoMath {
    public static void main(String[] args) {

        BigInteger i1 = new BigInteger("222222222222221");
        BigInteger i2 = new BigInteger("222222222222221");
        System.out.println(i1.add(i2));
        System.out.println(i1.multiply(i2));
        System.out.println(i1.divide(i2));
        System.out.println(i1.subtract(i2));


        BigDecimal b1 = new BigDecimal("3.55");
        BigDecimal b2 = new BigDecimal("2.12");
        System.out.println(b1.add(b2));
        System.out.println(b1.multiply(b2));
        //RoundingMode是一个枚举  up:向上加1   down:直接舍去 half_up：四舍五入
        System.out.println(b1.divide(b2,2, RoundingMode.HALF_UP));//四舍五入
        System.out.println(b1.subtract(b2));
    }

}
